#!/bin/bash

# 检查chronyd服务是否运行
if ! systemctl is-active chronyd >/dev/null 2>&1; then
    echo "[-] chrony服务未运行"
    exit 1
fi

# 检查chrony配置文件中是否配置了时间服务器
if ! grep -E "^(server|pool)" /etc/chrony.conf >/dev/null 2>&1; then
    echo "[-] chrony未配置时间服务器"
    exit 1
fi

# 检查chronyd是否以chrony用户运行
if ! grep -q "OPTIONS.*-u chrony" /etc/sysconfig/chronyd 2>/dev/null; then
    echo "[-] chronyd未配置为以chrony用户运行"
    exit 1
fi

echo "[+] chrony已正确配置并运行"
